﻿Imports System.Runtime.CompilerServices
Imports System.Text

''' <summary>
''' StringBuilder拡張メソッド
''' </summary>
''' <remarks></remarks>
Friend Module StringBuilderExtension
    ''' <summary>
    ''' 文字列が存在するかどうかを示します
    ''' </summary>
    ''' <param name="source"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()>
    Public Function Any(source As StringBuilder) As Boolean
        If source.Length = 0 Then
            Return False
        Else
            Return True
        End If
    End Function

    ''' <summary>
    ''' 区切り文字を追加します。文字が存在しない場合は追加しません
    ''' </summary>
    ''' <param name="source"></param>
    ''' <param name="delimiter"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()>
    Public Function AppendDelimiter(source As StringBuilder, delimiter As String) As StringBuilder
        If source Is Nothing Then Throw New ArgumentNullException("source")
        If delimiter Is Nothing Then Throw New ArgumentNullException("delimiter")

        If source.Length <> 0 Then
            source.Append(delimiter)
        End If
        Return source
    End Function
End Module